/**
 * 创建koa框架代码
 */

const Koa = require('koa');
const app = new Koa();
const { koaBody } = require('koa-body');

//加载路由信息
const router = require('./router')
app.use(koaBody());
app.use(router.routes())

//全局监听错误
app.on('error',(err,ctx)=>{
    ctx.body = err.message;
})


app.listen(3000,()=>{
    console.log('开启koa监听,端口:3000')
});